home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
memory
/
demm.zip
/
STDFUNC.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-10-08
|
17KB
|
272 lines
;*--------------------------------------------------------------------*
;* STDFUNC -- This is a standard set of Assembler Subroutines that *
;* are contained in the STDFUNC.LIB standard assembler *
;* linkage library. *
;* *
;* Author: J.C. Weilandt II Date: 10-07-86 Last Update: 10-08-86 *
;* *
;* Functions Contained: *
;* stdout -- output a single character to the standard out dev *
;* stdcrlf -- output a carriage return/line feed sequence stdout *
;* stdin -- input a single character with echo from stdin *
;* stdinne -- input a single character w/o echo from stdin *
;* dec8out -- converts 8-bit binary to decimal and prints *
;* dec16out -- converts 16-bit binary to decimal and prints *
;* return -- return to MS-DOS *
;* prtstr -- prints a string terminated by $ *
;* clrscr -- clear the video display screen *
;* hex8out -- convert 8-bit binary to display hex and print *
;* hex16out -- convert 16-bit binary to display hex and print *
;* *
;*--------------------------------------------------------------------*
;
codes segment ;dummy segment for assembler
public stdout ;so we can find it later
public stdcrlf ;so we can find it later
public stdin ;so we can find it later
public stdinne ;so we can find it later
public dec8out ;so we can find it later
public dec16out ;so we can find it later
public return ;so we can find it later
public prtstr ;so we can find it later
public clrscr ;so we can find it later
public hex8out ;so we can find it later
public hex16out ;so we can find it later
assume cs:codes ;dummy code segment fixup
;
;*--------------------------------------------------------------------*
;* stdout -- output a single character to standard output device *
;* *
;* call_seq mov al,_char_ ;move character to al register *
;* call stdout ;write character on stdout *
;*--------------------------------------------------------------------*
stdout proc far ;procedure header
push dx ;save the dx register pair
mov dl,al ;load character to print
mov ah,2 ;load DOS function number
int 21h ;issue DOS function call
pop dx ;restore dx register pair
ret ;return to caller
stdout endp ;procedure trailer
;*--------------------------------------------------------------------*
;* stdcrlf -- output a carriage return/line feed sequence to stdout *
;* *
;* call_seq call stdcrlf ;write out CR/LF combination *
;*--------------------------------------------------------------------*
stdcrlf proc far ;procedure header
push ax ;save the ax register pair
mov al,0dh ;load character to print
call stdout ;write out the carriage return
mov al,0ah ;load character to print
call stdout ;write out the line feed
pop ax ;restore ax register pair
ret ;return to caller
stdcrlf endp ;procedure trailer
;*--------------------------------------------------------------------*
;* stdin -- input a single character from standard input device *
;* *
;* call_seq call stdin ;read character from console *
;*--------------------------------------------------------------------*
stdin proc far ;procedure header
mov ah,1 ;load DOS function number
int 21h ;issue DOS function call
ret ;return to caller
stdin endp ;procedure trailer
;*--------------------------------------------------------------------*
;* stdinne -- input a single character from stdin with no echo *
;* *
;* call_seq call stdinne ;read character from cons w/o echo *
;*--------------------------------------------------------------------*
stdinne proc far ;procedure header
mov ah,8 ;load DOS function number
int 21h ;issue DOS function call
ret ;return to caller
stdinne endp ;procedure trailer
;*--------------------------------------------------------------------*
;* dec8out -- convert 8-bit binary to decimal and print to stdout *
;* *
;* call_seq mov dl,_bin_ ;move binary number to dl register *
;* call dec8out ;convert to decimal and print out *
;*--------------------------------------------------------------------*
dec8out proc far ;procedure header
push ds ;save data segment register
push di ;save di register pair
push dx ;save work register pair
push cx ;save count register pair
push ax ;save accumulator register pair
mov ax,seg tbuff ;get segment address of buffer
mov ds,ax ;put into data segment register
mov cx,0 ;initialize counter
mov di,offset tbuff ;point to buffer area
dec8out1:
push cx ;save counter register pair
mov al,dl ;AX now has the numerator
mov ah,0 ;clear upper half
mov cl,10 ;divisor of 10
div cl ;do the division
mov dl,al ;get the quotient
mov al,ah ;get the remainder
add al,30h ;make numeric display
mov [di],al ;put number into buffer
inc di ;point to the next byte
pop cx ;restore counter
inc cx ;count the digit
cmp dl,0 ;q.are we all done ??
jnz dec8out1 ;nope, go do more
dec8out2:
dec di ;back up through buffer
mov al,[di] ;get byte from buffer
call stdout ;write out the number
loop dec8out2 ;loop until cx=0
pop ax ;restore accumulator pair
pop cx ;restore counter pair
pop dx ;restore work register pair
pop di ;restore index pair
pop ds ;restore data segment pair
ret ;return to caller
tbuff dw 32(?) ;buffer storage
dec8out endp ;procedure trailer
;*--------------------------------------------------------------------*
;* dec16out -- convert 16-bit binary to decimal and print to stdout *
;*